<?php
require_once("conf/db_connection.php");

$id = $_GET["id"];
$return_str = "";
$incident_table_list = "";

$query_incident = "SELECT * FROM incident WHERE trip_detail_id='".$id ."'";
$result_incident = mysql_query($query_incident) or die("SELECT INCIDENT ".mysql_error());
$num_rows_inc = mysql_num_rows($result_incident);
if($num_rows_inc>0)
{
	while($row_incident = mysql_fetch_array($result_incident))
	{
		$incident_table_list .= "<tr class='h25'>
		<td class='incl label'>".$row_incident['incident_date']." ".$row_incident['incident_time']."</td>
		<td class='incl label'>".$row_incident['incident_type']."</td>
		<td class='incl label'>".$row_incident['caller']."</td>
		<td class='incl label'>".$row_incident['caller_mobile']."</td>
		</tr>";
	}
}
else
{
	$incident_table_list = "<td class='incl label' colspan='4' style='padding-top:30px;'>No Incident Record</td>";
}


$return_str = "<div id='div_inc_list' style='margin:25px 25px 0px 25px; padding: 0px auto;width:500px;height:400px;background-color:#FFFFFF;'>
<table id='pop_table' border='0' style='width:500px;'>
<thead style='height:15%;'>
<tr id='hor-minimalist-b'>
	<th>Date/Time</th>
	<th>Type</th>
	<th>Caller</th>
	<th>Mobile</th>
</tr>
</thead>
<tbody>
".$incident_table_list."
</tbody>
</table></div>";

$return_str .= "
<div id='div_add_inc' style='position:absolute;left:525px;top:0px;margin:25px 25px 25px 0px;padding:0px;width:450px;height:400px;background-color:#FFFFFF;'>
<input type='hidden' id='hf_inc_trip_id' value='".$id."'/>
<table id='pop_table' border='0' style='width:400px;'>
<thead style='height:2%;'>
<tr id='hor-minimalist-b'>
	<th colspan='4'>Add Incident</th>
</tr>
</thead>
<tbody>
<tr>
	<td class='label'>Date</td>
	<td class='td_input'><input class='inp' readonly='readonly' id='txt_inc_date' name='txt_inc_date' type='text' /></td>
	<td class='label'>Time</td>
	<td class='td_input'><input class='inp' id='txt_inc_time' name='txt_inc_time' type='text' value='".date('H:i')."' /></td>	
</tr>
<tr>
	<td class='label'>Caller</td>
	<td class='td_input'><input class='inp' id='txt_inc_caller' name='txt_inc_caller' type='text' /></td>	
	<td class='label'>Mobile</td>
	<td class='td_input'><input class='inp' id='txt_inc_mobile' name='txt_inc_mobile' type='text' /></td>	
</tr>
<tr>
	<td class='label'>Type of Call</td>
	<td class='td_input' colspan='3'><input class='textarea100 inp' id='txt_inc_type' name='txt_inc_type' type='text' /></td>	
</tr>

<tr>
	<td class='label'>Description</td>
	<td class='td_input' colspan='3'><textarea class='textarea100' id='txt_inc_remarks' name='txt_inc_remarks'></textarea></td>
</tr>
<tr>
	<td style='text-align:right;'><input onClick='saveIncident()' style='width:auto;' type='button' value='Submit' /></td>
	<td style='text-align:left;'><input onClick='closePopDiv()' style='width:auto;' type='button' value='Close' /></td>
</tr>
</tbody>
</table></div>
";
/*
<tr>
	<td class='label'>Location</td>
	<td class='td_input' colspan='3'><textarea class='textarea100' id='txt_inc_location' name='txt_inc_location'></textarea></td>
</tr>
*/
echo $return_str;
?>